package org.example.lysh.controller;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.lysh.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.view.RedirectView;

/**
 * @author liyishan
 * @date 2023/7/14 14:28
 * @apiNote
 */

@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("base/")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @GetMapping("/login")
    public RedirectView callBack(@RequestParam Long userId)  {
        try {
            loginService.login(userId);
        } catch (Exception e) {
            log.error("callBack error", e);
        }
        RedirectView redirectView = new RedirectView();
        redirectView.setUrl("https://mp.weixin.qq.com/s/m1SRsBG96kLJW5mPe4AVGA");
        return redirectView;
    }
}
